package cn.bluethink.eguan.rewardtask.controller;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.bluethink.eguan.core.security.Token;
import cn.bluethink.eguan.core.service.EgFileService;
import cn.bluethink.eguan.core.service.EgMemberService;
import cn.bluethink.eguan.core.service.EgResultService;
import cn.bluethink.eguan.core.service.EgStaffService;
import cn.bluethink.eguan.core.service.EgTavernService;
import cn.bluethink.eguan.model.core.EgFile;
import cn.bluethink.eguan.model.core.EgOType;
import cn.bluethink.eguan.model.core.EgObject;
import cn.bluethink.eguan.model.core.EgPurview;
import cn.bluethink.eguan.model.core.EgResult;
import cn.bluethink.eguan.model.core.EgTaskStatus;
import cn.bluethink.eguan.model.core.EgTavern;
import cn.bluethink.eguan.model.core.EgUser;
import cn.bluethink.eguan.model.rewardtask.EgReceiver;
import cn.bluethink.eguan.model.rewardtask.EgRewardTask;
import cn.bluethink.eguan.result.PageInfo;
import cn.bluethink.eguan.result.ResponseMessage;
import cn.bluethink.eguan.result.ResponseResult;
import cn.bluethink.eguan.rewardtask.filter.ReceiverFilter;
import cn.bluethink.eguan.rewardtask.service.EgReceiverService;
import cn.bluethink.eguan.rewardtask.service.EgRewardTaskService;
import cn.bluethink.eguan.utils.DateUtil;

/**
 * 悬赏任务揭榜者控制器
 * 
 * @author 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.2.0
 * @brief 驿馆+产品
 * @note 修订历史： 1.wanglei于2018/10/18设计并构建初始版本v0.2.0
 *       2.wanglei于2018/11/12修订需求，任务的创建者可以揭榜 3.wanglei于2018/11/15重新修订打赏时的账户处理逻辑
 *       4.wanglei于2018/11/22重新修订打赏，悬赏金为单人打赏金，每个用户首次打赏的数额不超过悬赏金数额，追赏的赏金不受悬赏金数额的限制，只要账户有钱可以一直打赏
 */
@CrossOrigin
@RestController
@RequestMapping("/eguan/v1.0/receiver")
public class EgReceiverController {

    @Autowired
    private HttpServletRequest request;

    @Autowired
    private EgRewardTaskService rewardTaskService;

    @Autowired
    private EgMemberService memberService;

    @Autowired
    private EgTavernService tavernService;

    @Autowired
    private EgStaffService staffService;

    @Autowired
    private EgReceiverService receiverService;

    @Autowired
    private EgFileService fileService;

    @Autowired
    private EgResultService resultService;

    /**
     * 领取悬赏任务 。 1.用户不是当前门派成员或不是驿馆的伙计不能领取. 2.只要是主动点击【我要揭榜】的,揭榜者状态直接为【进行中】状态。
     * 
     * @param tid
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK })
    @PostMapping("/claim")
    @Transactional(transactionManager = "eguanTransactionManager", rollbackFor = Exception.class)
    public ResponseResult<EgReceiver> claim(@RequestParam Long tid) throws Exception {
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        // 获取该悬赏任务详情
        EgRewardTask rewardTask = rewardTaskService.detail(tid);
        if (rewardTask == null) {
            new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 判断悬赏任务是否过期
        if (DateUtil.dateCompare(new Date(), rewardTask.getEtime()) > 0) {
            return new ResponseResult<>(ResponseMessage.OUT_OF_DATE);
        }
        // 如果当前用户已经揭过榜，不可再次揭榜
        if (receiverService.getById(tid, uid) != null) {
            return new ResponseResult<>(ResponseMessage.IS_EXIST);
        }
        // 获取悬赏任务的发布位置类型对象ID,以及位置对象ID
        Integer otype = rewardTask.getPos().getType().getOtid();
        Long oid = rewardTask.getPos().getId();
        if (otype.equals(EgOType.FACTION)) {
            // 根据门派ID和用户ID查找领取者信息,不是本门派成员不能领取
            if (memberService.queryById(oid, uid) == null) {
                return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
            }
        }
        if (otype.equals(EgOType.TAVERN)) {
            // 查询该驿馆信息(包括隶属的门派)
            EgTavern tavern = tavernService.getById(oid);
            if (tavern == null) {
                return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
            }
            // 获取门派的ID
            Long fid = tavern.getFaction().getId();
            if (fid == null) {
                // 门派的ID为空，说明该驿馆只隶属江湖。根据驿馆ID和用户ID查找领取者信息，不是驿馆中的伙计不能领取
                if (staffService.getById(oid, uid) == null) {
                    return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
                }
            }
            if (fid != null && fid > 0) {
                // 门派的ID存在，根据门派的ID和用户ID查找领取者信息,不是本门派成员不能领取
                if (memberService.queryById(fid, uid) == null) {
                    return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
                }
            }
        }
        // 获取悬赏任务的特有属性
        EgRewardTask reward = rewardTaskService.queryById(tid);
        if (reward == null) {
            return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 获取限制人数,以及已领取的人数之和
        Integer limit = reward.getLimit();
        Integer count = reward.getRvcount();
        if (limit > 0 && limit.equals(count)) {
            return new ResponseResult<>(ResponseMessage.LIMIT);
        }
        // 保存领取者,状态为【进行中】
        EgReceiver result = receiverService.saveReceiver(reward, uid, EgTaskStatus.STATUS_HANDLE);
        if (result != null) {
            return new ResponseResult<>(ResponseMessage.OK, result);
        }
        return new ResponseResult<>(ResponseMessage.CLAIM_FAIL);
    }

    /**
     * 指派悬赏任务。 1.发布者只能在悬赏任务发布前，进行指派操作。 2.每次指派时必须保证limit>=rvcount。
     * 3.只要是被指派成功的,领取者状态为【未开始】。 4.新修订：在江湖中发布江湖悬赏时，不能进行指派。但在江湖中驿馆发布悬赏时，允许指派给驿馆伙计。
     * 
     * @param tid
     * @param ruid
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @PostMapping("/dispatch")
    public ResponseResult<EgReceiver> dispatch(@RequestParam Long tid, @RequestParam Long ruid) throws Exception {
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        // 获取该悬赏任务详情
        EgRewardTask rewardTask = rewardTaskService.detail(tid);
        if (rewardTask == null) {
            new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 若在江湖中发布江湖悬赏时，不能进行指派
        EgObject pos = rewardTask.getPos();
        if (pos == null || (pos != null && pos.getType().getOtid().equals(EgOType.JIANGHU) && pos.getId().equals(0L))) {
            return new ResponseResult<>(ResponseMessage.DISPATCH_FAIL.getStatus(), "江湖中的悬赏任务不能指派！");
        }
        // 判断当前登录用户是否是任务创建者
        if (!uid.equals(rewardTask.getCuser().getId())) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
        }
        // 只能在悬赏任务发布前，进行指派操作
        if (!rewardTask.getStatus().equals(EgTaskStatus.STATUS_NEW)) {
            return new ResponseResult<>(ResponseMessage.DISPATCH_FAIL.getStatus(), "该任务已发布，不能指派！");
        }
        // 不能重复指派给同一人
        if (receiverService.getById(tid, ruid) != null) {
            return new ResponseResult<>(ResponseMessage.DISPATCH_FAIL.getStatus(), "不能重复指派给同一人！");
        }
        // 获取悬赏任务的特有属性
        EgRewardTask reward = rewardTaskService.queryById(tid);
        if (reward == null) {
            return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 获取限制人数(参与类型：固定人数),以及已领取的人数之和
        Integer limit = reward.getLimit();
        Integer count = reward.getRvcount();
        if (limit > 0 && limit.equals(count)) {
            return new ResponseResult<>(ResponseMessage.LIMIT.getStatus(), "悬赏任务已满额，不能指派！");
        }
        // 保存被指派者信息，状态为【未开始】
        EgReceiver result = receiverService.saveReceiver(reward, ruid, EgTaskStatus.STATUS_NEW);
        if (result != null) {
            return new ResponseResult<>(ResponseMessage.OK, result);
        }
        return new ResponseResult<>(ResponseMessage.DISPATCH_FAIL);
    }

    /**
     * 移除悬赏任务的被指派者。 1.发布者只能在悬赏任务发布前，进行移除操作。
     * 
     * @param tid
     * @param ruid
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @PostMapping("/remove")
    public ResponseResult<Long> remove(@RequestParam Long tid, @RequestParam Long ruid) throws Exception {
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        // 获取该悬赏任务详情
        EgRewardTask rewardTask = rewardTaskService.detail(tid);
        if (rewardTask == null) {
            return new ResponseResult<>(ResponseMessage.NOT_FOUND);
        }
        // 判断当前登录用户是否是任务创建者
        if (!uid.equals(rewardTask.getCuser().getId())) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
        }
        // 只能在悬赏任务发布前，进行移除操作
        if (!rewardTask.getStatus().equals(EgTaskStatus.STATUS_NEW)) {
            return new ResponseResult<>(ResponseMessage.DELETE_FAIL.getStatus(), "该任务已发布，不能移除！");
        }
        // 移除操作
        if (receiverService.remove(tid, ruid, null)) {
            return new ResponseResult<>(ResponseMessage.OK, ruid);
        }
        return new ResponseResult<>(ResponseMessage.DELETE_FAIL.getStatus(), "移除被指派者失败！");
    }

    /**
     * 放弃悬赏任务。 1.对于揭榜者而言，悬赏任务领取后，悬赏任务结束前均可以放弃； 2.对于发布者而言，没有放弃的说法。
     * 3.揭榜者放弃悬赏任务时需要删除之前上传的文件。
     * 
     * 
     * @param tid
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK })
    @PostMapping("/abandon")
    public ResponseResult<Long> abandon(@RequestParam Long tid) throws Exception {
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        // 获取该悬赏任务详情
        EgRewardTask rewardTask = rewardTaskService.detail(tid);
        if (rewardTask == null) {
            return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 判断当前用户是否是任务的领取者
        EgReceiver receiver = receiverService.getById(tid, uid);
        if (receiver == null) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS.getStatus(), "你不是该悬赏任务的领取者！");
        }
        // 领取者点击【完成】后不能进行【放弃】操作
        if (receiver.getStatus().equals(EgTaskStatus.STATUS_FINISH)) {
            return new ResponseResult<>(ResponseMessage.UNDELETE.getStatus(), "你已完成该任务，不能放弃！");
        }
        // 放弃操作
        if (receiverService.remove(tid, uid, receiver)) {
            return new ResponseResult<>(ResponseMessage.OK, tid);
        }
        return new ResponseResult<>(ResponseMessage.UNDELETE.getStatus(), "放弃悬赏任务失败！");
    }

    /**
     * 更新领取者的信息 (只更新状态)
     * 
     * @param receiver
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK })
    @PostMapping("/update")
    public ResponseResult<EgReceiver> update(@RequestBody EgReceiver receiver) throws Exception {
        // 需要被更新的揭榜者
        EgUser user = receiver.getUser();
        if (user == null || user.getId() == null || user.getId() == 0) {
            return new ResponseResult<>(ResponseMessage.NOTNULL_ID.getStatus(), "请求的领取者ID不能为空！");
        }
        // 上述揭榜者对应领取的任务
        EgRewardTask task = receiver.getTask();
        if (task == null || task.getId() == null || task.getId() == 0) {
            return new ResponseResult<>(ResponseMessage.NOTNULL_ID.getStatus(), "请求的悬赏任务ID不能为空！");
        }
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        // 验证当前用户是否是被更新的揭榜者本人
        if (!uid.equals(user.getId())) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
        }
        // 获取该悬赏任务详情
        EgRewardTask rewardTask = rewardTaskService.detail(task.getId());
        if (rewardTask == null) {
            new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 只有发布者开始了悬赏任务，领取者才能修改状态
        if (rewardTask.getStatus().equals(EgTaskStatus.STATUS_NEW)) {
            return new ResponseResult<>(ResponseMessage.UPDATE_FAIL.getStatus(), "该悬赏任务尚未发布，不能更新状态！");
        }
        // 获取该领取者的信息
        EgReceiver oldReceiver = receiverService.getById(task.getId(), user.getId());
        if (oldReceiver == null) {
            return new ResponseResult<>(ResponseMessage.NOT_FOUND);
        }
        // 更新领取者的状态
        EgReceiver result = receiverService.updateStatus(oldReceiver, receiver, rewardTask);
        if (result != null) {
            return new ResponseResult<>(ResponseMessage.OK, result);
        }
        return new ResponseResult<>(ResponseMessage.UPDATE_FAIL.getStatus(), "更新领取者状态失败！");
    }

    /**
     * 对领取者打赏。 1.悬赏任务状态为【进行中】时，发布人可打赏已经完成悬赏的揭榜者。
     * 2.打赏成功，打赏者可以再次追赏；首次打赏的金币不超过悬赏金币，追赏不限制。
     * 
     * @param tid
     * @param ruid
     * @param bt
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @PostMapping("/reward")
    public ResponseResult<EgReceiver> reward(@RequestParam Long tid, @RequestParam Long ruid, @RequestParam Integer bt)
            throws Exception {
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        // 获取该悬赏任务详情
        EgRewardTask rewardTask = rewardTaskService.detail(tid);
        if (rewardTask == null) {
            return new ResponseResult<>(ResponseMessage.NOT_FOUND);
        }
        // 判断当前登录用户是否是任务创建者
        if (!uid.equals(rewardTask.getCuser().getId())) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS);
        }
        // 获取任务揭榜者信息
        EgReceiver receiver = receiverService.getById(tid, ruid);
        if (receiver == null) {
            return new ResponseResult<>(ResponseMessage.NOT_FOUND);
        }
        // 只有悬赏任务未结束【进行中】，并且该领取者的状态为【完成】
        if (!rewardTask.getStatus().equals(EgTaskStatus.STATUS_HANDLE)
                || !receiver.getStatus().equals(EgTaskStatus.STATUS_FINISH)) {
            return new ResponseResult<>(ResponseMessage.REWARD_FAIL.getStatus(), "悬赏任务已结束或领取者尚未完成!");
        }
        // 打赏的金币必须大于0
        if (bt == null || (bt != null && bt <= 0)) {
            return new ResponseResult<>(ResponseMessage.REWARD_FAIL.getStatus(), "打赏的金币不能为空并且大于0！");
        }
        // 获取悬赏任务的特有属性
        EgRewardTask reward = rewardTaskService.queryById(tid);
        if (reward == null) {
            return new ResponseResult<>(ResponseMessage.NOT_FOUND);
        }
        // 首次打赏的金币不超过悬赏金币
        if (receiver.getReward() == 0 && bt > reward.getBtCoin()) {
            return new ResponseResult<>(ResponseMessage.REWARD_FAIL.getStatus(), "首次打赏,金币不超过悬赏金！");
        }
        // 进行打赏/追赏
        if (receiverService.reward(rewardTask, reward, receiver, bt)) {
            return new ResponseResult<>(ResponseMessage.OK, receiver);
        }
        return new ResponseResult<>(ResponseMessage.REWARD_FAIL);

    }

    /**
     * 根据过滤条件查询悬赏任务接收者列表。
     * 1.根据悬赏任务ID查询揭榜者列表：
     * （1）需要提交任务结果的悬赏任务，展示进行中和已完成的揭榜者，按照揭榜者提交结果的时间降序排序；
     * （2）无需提交任务结果的悬赏任务，只展示已完成的揭榜者，按照揭榜者完成时间降序排序；
     * 2.根据当前登录用户查询我领取的悬赏任务（查询领取人列表，返回信息包括悬赏任务基本信息（含位置信息）），可根据状态筛选，根据领取时间由近及远排序。
     * 
     * @param filter
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @PostMapping("/query")
    public ResponseResult<PageInfo<EgReceiver>> query(@RequestBody ReceiverFilter filter) throws Exception {
        // String token = request.getHeader("Authorization");
        Long uid = (Long) request.getAttribute("userId");
        PageInfo<EgReceiver> pageInfo = receiverService.query(filter, uid);
        return new ResponseResult<>(ResponseMessage.OK, pageInfo);
    }

    /**
     * 提交结果
     * 
     * @param result
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @PostMapping("/subresult")
    public ResponseResult<EgResult> submitResult(@RequestBody EgResult result) throws Exception {
        // 针对哪个悬赏任务提交结果
        Long tid = result.getObj().getId();
        if (tid == null || tid == 0L) {
            return new ResponseResult<>(ResponseMessage.NOTNULL_CONTENT.getStatus(), "该结果所属的任务ID不能为空！");
        }
        Long uid = (Long) request.getAttribute("userId");
        // 判断当前用户是否是任务的领取者
        EgReceiver receiver = receiverService.getById(tid, uid);
        if (receiver == null) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS.getStatus(), "你不是该悬赏任务的领取者！");
        }
        // 揭榜者已结束该任务，不可上传或重新上传任务结果
        if (receiver.getStatus().equals(EgTaskStatus.STATUS_FINISH)) {
            return new ResponseResult<>(ResponseMessage.DELETE_FAIL.getStatus(), "您已完成该悬赏任务，不可提交结果！");
        }
        // 1 获取待提交的结果描述
        String des = result.getDes();
        // 2 获取提交的文件列表对象
        List<EgFile> fileList = result.getFileList();
        if (StringUtils.isBlank(des) && (fileList == null || fileList.size() == 0)) {
            return new ResponseResult<>(ResponseMessage.CREATE_FAIL.getStatus(), "结果描述和附件不能同时为空！");
        }
        if (fileList != null && fileList.size() > 0) {
            for (EgFile file : fileList) {
                if (StringUtils.isBlank(file.getFile()) || StringUtils.isBlank(file.getName())) {
                    return new ResponseResult<>(ResponseMessage.NULL_REQUEST.getStatus(), "文件标识和文件名不能为空！");
                }
                file.setUploader(new EgUser(uid, null, null));
                file.setPos(new EgObject(tid, null, new EgOType(EgOType.REWARD_TASK, null)));
            }
        }
        result.setUser(new EgObject(uid, null, null));
        // 提交结果
        EgResult submitResult = receiverService.submitResult(result, receiver);
        if (submitResult == null) {
            return new ResponseResult<>(ResponseMessage.CREATE_FAIL);
        }
        return new ResponseResult<>(ResponseMessage.OK, submitResult);
    }

    /**
     * 根据任务的ID和当前揭榜者获取其提交的结果
     * 
     * @param tid
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @GetMapping("/getresult")
    public ResponseResult<EgResult> getResult(@RequestParam Long tid) throws Exception {
        Long uid = (Long) request.getAttribute("userId");
        EgReceiver receiver = receiverService.getById(tid, uid);
        if (receiver == null) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS.getStatus(), "你不是该悬赏任务的领取者！");
        }
        // 获取提交的结果对象
        EgResult oldResult = receiver.getResult();
        if (oldResult == null) {
            return new ResponseResult<>(ResponseMessage.OK, null);
        }
        // 返回的结果对象
        EgResult result = null;
        if (oldResult.getId() != null && oldResult.getId() > 0) {
            // 获取提交的结果详情
            result = resultService.detail(oldResult.getId());
            result.setType(new EgOType(EgOType.RECEIVER, null));
        }
        if (result != null) {
            return new ResponseResult<>(ResponseMessage.OK, result);
        }
        return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
    }

    /**
     * 删除提交的文件列表（单个删除）
     * 
     * @param fileId
     * @return
     * @throws Exception
     */
    @Token(purviews = { EgPurview.PERSONAL_REWARD_TASK, EgPurview.TEAM_REWARD_TASK })
    @PostMapping("/delresult")
    public ResponseResult<Long> delResult(@RequestParam Long fileId) throws Exception {
        // 根据文件主键ID获取文件详情
        EgFile file = fileService.detail(fileId);
        if (file == null) {
            return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 获取文件的上传位置对象
        Long posId = file.getPos().getId();
        Long uid = (Long) request.getAttribute("userId");
        // 判断当前用户是否是任务的领取者
        EgReceiver receiver = receiverService.getById(posId, uid);
        if (receiver == null) {
            return new ResponseResult<>(ResponseMessage.INADEQUATE_PERMISSIONS.getStatus(), "你不是该悬赏任务的领取者！");
        }
        // 揭榜者已结束该任务，不可删除
        if (receiver.getStatus().equals(EgTaskStatus.STATUS_FINISH)) {
            return new ResponseResult<>(ResponseMessage.DELETE_FAIL.getStatus(), "您已完成该悬赏任务，不可删除提交结果！");
        }
        // 获取揭榜者的结果对象ID
        Long resultOid = receiver.getResult().getId();
        EgResult result = resultService.detail(resultOid);
        if (result == null) {
            return new ResponseResult<>(ResponseMessage.DATA_NOT_FOUND);
        }
        // 执行结果删除操作
        if (receiverService.delResult(fileId, receiver, result)) {
            return new ResponseResult<>(ResponseMessage.OK, fileId);
        }
        return new ResponseResult<>(ResponseMessage.DELETE_FAIL);
    }

}
